package com.mgq.design.chainofresponsibility.c1;

import java.util.function.*;

/**
 * <b>功能：</b>main类<br>
 * <b>Copyright TCSL</b>
 * <li>版本&nbsp;&nbsp;&nbsp;&nbsp;修改日期&nbsp;&nbsp;&nbsp;&nbsp;部　　门&nbsp;&nbsp;&nbsp;&nbsp;作　者&nbsp;&nbsp;&nbsp;&nbsp;变更内容</li><hr>
 * <li>v1.0&nbsp;&nbsp;&nbsp;&nbsp;20220425&nbsp;&nbsp;营业后台&nbsp;&nbsp;&nbsp;&nbsp;马广奇&nbsp;&nbsp;&nbsp;&nbsp;创建类</li>
 * <br><br>
 *
 * @author 马广奇
 * @version 2022-04-25 17:20
 */
public class Client {
    public static void main(String[] args) {
       // AbstractLogger logger = chainLog();
        //logger.logMessage(AbstractLogger.DEBUG,"我是debug信息");
        //logger.logMessage(AbstractLogger.ERROR,"我是错误信息");
        //logger.logMessage(AbstractLogger.INFO,"我是INFO信息");

        Consumer<String> errorLog = s -> System.out.println("ERROR:" + s);

        Consumer<String> consoleLogger = s -> System.out.println("控制台:" + s);

        Consumer<String> fileLogger = s -> System.out.println("文件:" + s);

        Consumer<String> consumer = errorLog.andThen(consoleLogger).andThen(fileLogger);
        consumer.accept("我是错误信息");
    }

    private static AbstractLogger chainLog() {
        AbstractLogger errorLog = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.DEBUG);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.INFO);

        errorLog.setNextLogger(consoleLogger);
        consoleLogger.setNextLogger(fileLogger);
        return errorLog;

    }
}
